package com.second.app.thread.wait.p_c_1;


import com.second.app.thread.wait.p_c.ProduceConsumeDemo;

/**
 * @Author GYZ
 * <pre>
 *
 * </pre>
 */
public class MainDemoRun {

    public static void main(String[] args) {
        ProduceConsumeMore produceConsumeDemo = new ProduceConsumeMore("ABC");
        for (int i=0;i<2;i++){
            new Thread(() -> {
                while (true) {
                    produceConsumeDemo.setValue();
                }
            }, "生产线程-"+i).start();
        }

        for (int j=0;j<2;j++){
            new Thread(() -> {
                while (true) {
                    produceConsumeDemo.getValue();
                }
            }, "消费线程-"+j).start();
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Thread[] threads = new Thread[Thread.currentThread().getThreadGroup().activeCount()];
        for (int i = 0; i < threads.length; i++) {
            System.out.println(threads[i].getName()+" "+threads[i].getState());
        }

    }
}

